package com.csdj.t309springboot.utils;
import org.springframework.beans.factory.annotation.Value;
import java.util.TreeMap;

public class SignurateUtil {
//    @Value("${data.accessKey}")
//    private static String accessKey;
//    @Value("${data.accessSecret}")
//    private String accessSecret;

    /**
     * yan zheng qian ming
     * @param map
     * @param sign
     * @return
     */
    public static boolean checkSign(TreeMap<String,String> map,String sign){
        String accessKey = "wienq31fj2ijsf21f2g3";
        StringBuffer sbf = new StringBuffer();
        map.entrySet().forEach(item ->{
            sbf.append(item.getKey()).append("#").append(item.getValue()).append("&");
        });
        sbf.append("accessKey=").append(accessKey);
        String hash = EncryptUtil.getSha256(sbf.toString());
        return sign.equals(hash);
    }


}
